package cn.itcast.order.exceptionhandler;

import cn.itcast.order.common.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.ArrayList;
import java.util.List;

/**
 * @author sxt
 * @version 1.0
 * @description TODO
 * @date 2024/4/24 15:50
 */
@RestControllerAdvice
@Slf4j
public class MyExceptionHandler {

    @ExceptionHandler(Exception.class)
    public ResponseResult commonExceptionHandle(Exception exception) {
        log.error(exception.getMessage());
        return ResponseResult.error("请求异常", exception.getMessage());
    }

}
